<?php include("includes/session.php"); ?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title><?php echo $lang['PAGE_TITLE_EDIT_PROFILE']; ?></title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=<?php echo GOOGLE_KEY; ?>"
		type="text/javascript">
	</script>
    <script type="text/javascript">
    function initialize()
	{
      if (GBrowserIsCompatible())
	  {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(0, 0), 1);
        map.setUIToDefault();
        map.setMapType(G_HYBRID_MAP);
		var marker = new GMarker(new GLatLng(0, 0));
		<?php
		if ($session->userinfo["longitude"])
		{
			$location = $session->userinfo["latitude"].",".$session->userinfo["longitude"];
			echo "marker = new GMarker(new GLatLng($location));";
			echo "map.setCenter(new GLatLng($location), 7);";
			echo "map.addOverlay(marker);";
		}
		?>

		GEvent.addListener(map,"click", function(overlay, latlng)
			{
				if (latlng)
				{
					map.removeOverlay(marker);
					//var myHtml = "The GPoint value is: " + map.fromLatLngToDivPixel(latlng) + " at zoom level " + map.getZoom();
					//map.openInfoWindow(latlng, myHtml);
					document.getElementById("LatLong").value = latlng;
					marker = new GMarker(latlng);
					map.addOverlay(marker);
				}
			});
      }
    }
    </script>
<?php include("header.php"); ?>
	<center>
	<table cellpadding="0" cellspacing="0" width="93%">
	<tr>
		<td align="left">
			<br /><br />
			<?php
			if(!$session->logged_in)
			{
				echo "<center><h3>You must be logged in to edit your profile.</h3></center>";
			}
			else
			{
				if(isset($_SESSION['editUserFieldSuccess']))
				{
					if($_SESSION['editUserFieldSuccess'])
					{
						echo "<center><table cellpadding=\"10\" cellspacing=\"0\" class=\"border\" width=\"50%\">";
						echo "<tr><td><center><h3>Edit User Profile Successful!</h3></center></td></tr>";
						echo "</table></center>";
						echo "<br /><br />";
					}
					else
					{
						echo "<center><table cellpadding=\"10\" cellspacing=\"0\" class=\"border\" width=\"50%\">";
						echo "<tr><td>";
						echo "<center><h3>Edit User Profile Failed!</h3></center>";
						echo "<center>".$form->error("content")."</center><br />";
						echo "<center>".$form->value("content")."</center>";
						echo "</td></tr>";
						echo "</table></center>";
						echo "<br /><br />";
					}
					unset($_SESSION['editUserFieldSuccess']);
				}
			?>
			<table cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td valign="top">
					<center>
					<form action="includes/process.php" method="post" enctype="multipart/form-data">
					<input type="hidden" name="subUploadProfilePic" value="<?php echo $session->username; ?>" />
					<table cellpadding="10" cellspacing="0" class="border" width="100%">
					<tr><td class="title" align="left"><?php echo $lang['PROFILE_FOTO']; ?></td></tr>
					<tr>
						<td>
							<center><?php echo $form->error('uploading'); ?></center>
							<center><img border="1" src="<?php if($session->userinfo['profilePic']==''){ echo DEFAULT_PROFILE_PIC; }else{ echo $session->userinfo['profilePic']; } ?>" width="200" height="200" /></center>
							<center><font size="-2" color="#666666">200 x 200, JPEG, GIF, 50KB</font></center>
							<br />
							<center><input type="file" name="file" id="file" /></center>
							<center><?php echo $form->error('upload'); ?></center>
						</td>
					</tr>
					<tr>
						<td align="right"><input type="submit" name="submit" value="Upload" /></td>
					</tr>
					</table>
					</form>
					</center>
					<br />
					<center>
					<table cellpadding="10" cellspacing="0" class="border" width="100%">
					<tr><td class="title" align="left"><?php echo $lang['PROFILE_INFO']; ?></td></tr>
					<tr>
						<td>
							<center>
							<form action="includes/process.php" method="POST">
							<table border="0" cellspacing="0" cellpadding="3">
							<tr>
								<td colspan="2"><center><?php echo $lang['PROFILE_ALL_FIELD_OPTIONAL']; ?></center></td>
							</tr>
							<tr>
								<td align="right"><?php echo $lang['PROFILE_NAME']; ?></td>
								<td align="left"><input type="text" name="fname" maxlength="30" style="background-color: #bcc6e1;" value="<? echo $session->userinfo['fname']; ?>" /></td>
								<td><? echo $form->error("fname"); ?></td>
							</tr>
							<tr>
								<td align="right"><?php echo $lang['PROFILE_SURNAME']; ?></td>
								<td align="left"><input type="text" name="lname" maxlength="30" style="background-color: #bcc6e1;" value="<? echo $session->userinfo['lname']; ?>" /></td>
								<td><? echo $form->error("lname"); ?></td>
							</tr>
							<tr>
								<td align="right"><?php echo $lang['PROFILE_GENDER']; ?></td>
								<td align="left">
									<input type="radio" <? if($session->userinfo['gender']=="Male"){ echo "checked=\"checked\""; } ?> name="gender" value="Male">Male&nbsp;&nbsp;&nbsp;
									<input type="radio" <? if($session->userinfo['gender']=="Female"){ echo "checked=\"checked\""; } ?> name="gender" value="Female">Female
								</td>
							</tr>
							<tr>
								<td colspan="2"><br /><hr width="90%" size="1px" color="#999999"><br /></td>
							</tr>
							<tr>
								<td align="right"><?php echo $lang['PROFILE_COUNTRY']; ?></td>
								<td align="left">
								<select name="country" style="background-color: #bcc6e1;">
									<?php $result = $database->query("SELECT * FROM ".TBL_COUNTRIES);
										$num_rows = mysql_num_rows($result);
										for($i=0;$i<$num_rows;$i++)
										{
											$country = mysql_result($result,$i,"country");
											$code = mysql_result($result,$i,"code");
											echo "<option value=\"$code\" ";
											if($session->userinfo['country']==$code)
											{
												echo "selected=\"selected\" ";
											}
											echo ">$country</option>";
										}
									 ?>
								</select>
								</td>
							</tr>
							<tr>
								<td align="right"><?php echo $lang['PROFILE_REGION']; ?></td>
								<td align="left"><input type="text" name="state" maxlength="30" style="background-color: #bcc6e1;" value="<? echo $session->userinfo['state']; ?>" /></td>
								<td><? echo $form->error("state"); ?></td>
							</tr>
							<tr>
								<td align="right"><?php echo $lang['PROFILE_CITY']; ?></td>
								<td align="left"><input type="text" name="city" maxlength="30" style="background-color: #bcc6e1;" value="<? echo $session->userinfo['city']; ?>" /></td>
								<td><? echo $form->error("city"); ?></td>
							</tr>
							<tr>
								<td align="right"><?php echo $lang['PROFILE_ZIP']; ?></td>
								<td align="left"><input type="text" name="zip" maxlength="9" style="background-color: #bcc6e1;" value="<? echo $session->userinfo['zip']; ?>" /></td>
								<td><? echo $form->error("zip"); ?></td>
							</tr>
							<tr>
								<td colspan="2" align="right">
									<input type="hidden" name="subEditUserInfo" value="1">
									<input type="submit" value="Save">
								</td>
							</tr>
							</table>
							</form>
							</center>
						</td>
					</tr>
					</table>
					</center>
					<br />
					<center>
					<table cellpadding="10" cellspacing="0" class="border" width="100%">
					<tr><td class="title" align="left"><?php echo $lang['PROFILE_CONTACT_INFO']; ?></td></tr>
					<tr>
						<td>
							<center>
							<form action="includes/process.php" method="POST">
							<table border="0" cellspacing="0" cellpadding="3">
							<tr>
								<td align="right"><?php echo $lang['PROFILE_EMAIL']; ?></td>
								<td align="left"><input type="text" name="email" maxlength="50" style="background-color: #bcc6e1;" value="<? echo $session->userinfo['email']; ?>" /></td>
								<td><? echo $form->error("email"); ?></td>
							</tr>
							<tr>
								<td align="right">AIM:</td>
								<td align="left"><input type="text" name="aim" maxlength="30" style="background-color: #bcc6e1;" value="<? echo $session->userinfo['aim']; ?>" /></td>
								<td><? echo $form->error("aim"); ?></td>
							</tr>
							<tr>
								<td align="right">MSN:</td>
								<td align="left"><input type="text" name="msn" maxlength="50" style="background-color: #bcc6e1;" value="<? echo $session->userinfo['msn']; ?>" /></td>
								<td><? echo $form->error("msn"); ?></td>
							</tr>
							<tr>
								<td align="right">Yahoo:</td>
								<td align="left"><input type="text" name="yahoo" maxlength="50" style="background-color: #bcc6e1;" value="<? echo $session->userinfo['yahoo']; ?>" /></td>
								<td><? echo $form->error("yahoo"); ?></td>
							</tr>
							<tr>
								<td align="right">ICQ:</td>
								<td align="left"><input type="text" name="icq" maxlength="50" style="background-color: #bcc6e1;" value="<? echo $session->userinfo['icq']; ?>" /></td>
								<td><? echo $form->error("icq"); ?></td>
							</tr>
							<tr>
								<td align="right">Skype:</td>
								<td align="left"><input type="text" name="skype" maxlength="50" style="background-color: #bcc6e1;" value="<? echo $session->userinfo['skype']; ?>" /></td>
								<td><? echo $form->error("skype"); ?></td>
							</tr>
							<tr>
								<td align="right">Jabber/Gtalk IM:</td>
								<td align="left"><input type="text" name="jabber" maxlength="50" style="background-color: #bcc6e1;" value="<? echo $session->userinfo['jabber']; ?>" /></td>
								<td><? echo $form->error("jabber"); ?></td>
							</tr>
							<tr>
								<td colspan="2" align="right">
									<input type="hidden" name="subEditContactInfo" value="1">
									<input type="submit" value="Save">
								</td>
							</tr>
							</table>
							</form>
							</center>
						</td>
					</tr>
					</table>
					</center>
					<br />
					<center>
					<table cellpadding="10" cellspacing="0" class="border" width="100%">
					<tr><td class="title" align="left"><?php echo $lang['PROFILE_LOCATION']; ?></td></tr>
					<tr>
						<td>
							<center>
							<form action="includes/process.php" method="POST">
							<table border="0" cellspacing="0" cellpadding="3">
							<tr>
								<td align="left">
									<div id="map_canvas" style="width: 400px; height: 300px"></div>
								</td>
							</tr>
							<tr>
								<td colspan="2" align="right">
									<input type="hidden" id="LatLong" name="LatLong">
									<input type="hidden" name="subEditLocation" value="1">
								</td>
							</tr>
							<tr>
								<td>
									<table width="100%">
									<tr>
										<td align="left">
											<?php echo $lang['PROFILE_SET_LOCATION']; ?>
										</td>
										<td align="right">
											<input type="submit" value="Save">
										</td>
									</tr>
									</table>
								</td>
							</tr>
							</table>
							</form>
							</center>
						</td>
					</tr>
					</table>
					</center>
					<br />
					<center>
					<table cellpadding="10" cellspacing="0" class="border" width="100%">
					<tr><td class="title" align="left"><?php echo $lang['PROFILE_PREFS']; ?></td></tr>
					<tr>
						<td>
							<center>
							<form action="includes/process.php" method="POST">
							<table border="0" cellspacing="0" cellpadding="3">
							<tr>
								<td align="right"><input type="checkbox" <?php if($session->userinfo['messageNotify']=='1'){ echo "checked=\"checked\""; } ?> name="messageNotify" value="1"></td>
								<td align="left"><?php echo $lang['PROFILE_PREFS_SENDMAIL']; ?></td>
							</tr>
							<tr>
								<td align="right"><input type="checkbox" <?php if($session->userinfo['displayEmail']=='1'){ echo "checked=\"checked\""; } ?> name="displayEmail" value="1"></td>
								<td align="left"><?php echo $lang['PROFILE_PREFS_SHOWMAIL']; ?></td>
							</tr>
							<tr>
								<td colspan="2" align="right">
									<input type="hidden" name="subEditPreferences" value="1">
									<input type="submit" value="Save">
								</td>
							</tr>
							</table>
							</form>
							</center>
						</td>
					</tr>
					</table>
					</center>
				</td>
				<td width="10px"></td>
				<td valign="top">
					<center>
					<table cellpadding="10" cellspacing="0" class="border">
					<tr><td class="title" align="left"><?php echo $lang['PROFILE_ABOUTME']; ?>:</td></tr>
					<tr>
						<td>
							<center>
							<form action="includes/process.php" method="POST">
							<table border="0" cellspacing="0" cellpadding="3">
							<tr>
								<td><textarea name="content" rows="5" cols="50" style="background-color: #bcc6e1;"><? echo $session->userinfo['thoughts']; ?></textarea></td>
							</tr>
							<tr>
								<td align="right">
									<input type="hidden" name="subEditUserField" value="thoughts">
									<input type="submit" value="Save">
								</td>
							</tr>
							</table>
							</form>
							</center>
						</td>
					</tr>
					</table>
					</center>
					<br />
					<center>
					<table cellpadding="10" cellspacing="0" class="border">
					<tr><td class="title" align="left"><?php echo $lang['PROFILE_SKILLS']; ?></td></tr>
					<tr>
						<td>
							<center>
							<form action="includes/process.php" method="POST">
							<table border="0" cellspacing="0" cellpadding="3">
							<tr>
								<td><textarea name="content" rows="5" cols="50" style="background-color: #bcc6e1;"><? echo $session->userinfo['skills']; ?></textarea></td>
							</tr>
							<tr>
								<td align="right">
									<input type="hidden" name="subEditUserField" value="skills">
									<input type="submit" value="Save">
								</td>
							</tr>
							</table>
							</form>
							</center>
						</td>
					</tr>
					</table>
					</center>
					<br />
					<center>
					<table cellpadding="10" cellspacing="0" class="border">
					<tr><td class="title" align="left"><?php echo $lang['PROFILE_CONTRIB']; ?></td></tr>
					<tr>
						<td>
							<center>
							<form action="includes/process.php" method="POST">
							<table border="0" cellspacing="0" cellpadding="3">
							<tr>
								<td><textarea name="content" rows="5" cols="50" style="background-color: #bcc6e1;"><? echo $session->userinfo['provisions']; ?></textarea></td>
							</tr>
							<tr>
								<td align="right">
									<input type="hidden" name="subEditUserField" value="provisions">
									<input type="submit" value="Save">
								</td>
							</tr>
							</table>
							</form>
							</center>
						</td>
					</tr>
					</table>
					</center>
					<br />
				</td>
			</tr>
			</table>
			<?php
			}
			?>
		</td>
	</tr>
	</table>
	</center>
<?php include("footer.php"); ?>